import puppeteer from 'puppeteer';

const htmlPath = './dist/example/index.html';
const outputPath = './dist/screenshot.png';

const resolve = (patname) => new URL(patname, import.meta.url).href;

(async () => {
    const browser = await puppeteer.launch({
        // 禁止浏览器安全策略，以访问本地资源文件
        args: ['--disable-web-security'],
    });
    const page = await browser.newPage();

    await page.goto(resolve(htmlPath), { waitUntil: 'networkidle0' });
    await page.screenshot({ path: outputPath });
    await browser.close();
})();
